package rocksea.com.wechat

import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import butterknife.BindView
import butterknife.ButterKnife

/**
 * Created by Mrw on 2018/1/7.
 *
 */
class MainActivity:AppCompatActivity(),MainPrenster
{
    @BindView(R.id.Text)
    private lateinit var infoText: TextView

    override fun disMovieList(json: String)
    {
        infoText.text = json
    }
    override fun onError(error: String)
    {
        infoText.text = error
    }
    override fun onLoading()
    {
        Toast.makeText(this,"loading",Toast.LENGTH_LONG).show()
    }
    override fun startRequest()
    {
        HttpCenter.instance.getMovieList(this)
    }
    @SuppressLint("WrongViewCast")
    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main_layout)
        ButterKnife.bind(this@MainActivity)
        Log.i("MainActivity::","Hello Kotlin World!")
        val button = findViewById<Button>(R.id.Button)
        button.setOnClickListener(
        {
            startRequest()
            Toast.makeText(this,"Hello World ${button.text}",Toast.LENGTH_LONG).show()
        })
    }
}
